package com.twu.bm.football;

import java.io.PrintStream;
import java.util.Set;

public class League {

    private Set<Coach> coaches;
    private Set<Player> players;

    public League(Set<Player> playersList, Set<Coach> coachList) {
        this.players = playersList;
        this.coaches = coachList;
    }

    public void print(PrintStream printStream) {
        printStream.println("PLAYERS:");
        for (Player player : players) {
            player.print(printStream);
            printStream.println();
        }

        printStream.println("COACHES:");
        for (Coach coach : coaches) {
            coach.print(printStream);
            printStream.println();
        }
    }

    public Player matchPlayer(String name, String number) {
        for (Player player : players) {
            if (player.checkMatches(name, number))
                return player;
        }
        return null;
    }
}
